//
//  U9AccountManager.m
//  U9WatchGame
//
//  Created by uuu9 on 2017/8/17.
//  Copyright © 2017年 UUU9. All rights reserved.
//

#import "U9AccountManager.h"
#import "U9EncryptManager.h"
#import "U9AccountModel.h"

@implementation U9AccountManager

+ (void)modifyNickNameWithUserid:(NSString *)uid andNickName:(NSString *)name andSessionid:(NSString *)sessionid andCompletionHandle:(void(^)(U9AccountModel *model,NSError *error))complete{
    NSString *param = [NSString stringWithFormat:@"userid=%@&nickname=%@&sessionid=%@",uid,name,sessionid];
    [self EncryptPOST:[NSString stringWithFormat:@"%@%@",Api_URL,kModifyNickName] parameters:param completionHandler:^(id responseObj, NSError *error) {
        U9AccountModel *model = [U9AccountModel mj_objectWithKeyValues:responseObj];
        if (model.error_code != 0) {
            error = [self createError:model.error_msg];
        }
        complete(model,error);
    }];
}


#pragma mark 修改密码
+ (void)modifyPasswordWithLoginName:(NSString *)loginname andPassword:(NSString *)passwd andCode:(NSString *)code andCompletionHandle:(void(^)(U9AccountModel *model,NSError *error))complete{
    NSString *param = [NSString stringWithFormat:@"loginname=%@&passwd=%@&code=%@",loginname,[U9EncryptManager convertPassword:passwd],code];
    [self EncryptPOST:[NSString stringWithFormat:@"%@%@",Api_URL,kModifyPassword]
            parameters:param
    completionHandler:^(id responseObj, NSError *error) {
        U9AccountModel *model = [U9AccountModel mj_objectWithKeyValues:responseObj];
        if (model.error_code != 0) {
            error = [self createError:model.error_msg];
        }
        complete(model,error);
    }];
}

@end
